package com.avamanager.app.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.avamanager.common.annotation.Log;
import com.avamanager.common.core.controller.BaseController;
import com.avamanager.common.core.domain.AjaxResult;
import com.avamanager.common.enums.BusinessType;
import com.avamanager.app.domain.AppScore;
import com.avamanager.app.service.IAppScoreService;
import com.avamanager.common.utils.poi.ExcelUtil;
import com.avamanager.common.core.page.TableDataInfo;

/**
 * 成绩信息Controller
 * 
 * @author FenvyYe
 * @date 2022-08-15
 */
@RestController
@RequestMapping("/app/score")
public class AppScoreController extends BaseController
{
    @Autowired
    private IAppScoreService appScoreService;

    /**
     * 查询成绩信息列表
     */
    @PreAuthorize("@ss.hasPermi('app:score:list')")
    @GetMapping("/list")
    public TableDataInfo list(AppScore appScore)
    {
        startPage();
        List<AppScore> list = appScoreService.selectAppScoreList(appScore);
        return getDataTable(list);
    }

    /**
     * 导出成绩信息列表
     */
    @PreAuthorize("@ss.hasPermi('app:score:export')")
    @Log(title = "成绩信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AppScore appScore)
    {
        List<AppScore> list = appScoreService.selectAppScoreList(appScore);
        ExcelUtil<AppScore> util = new ExcelUtil<AppScore>(AppScore.class);
        util.exportExcel(response, list, "成绩信息数据");
    }

    /**
     * 获取成绩信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('app:score:query')")
    @GetMapping(value = "/{scoreId}")
    public AjaxResult getInfo(@PathVariable("scoreId") Long scoreId)
    {
        return AjaxResult.success(appScoreService.selectAppScoreByScoreId(scoreId));
    }

    /**
     * 新增成绩信息
     */
    @PreAuthorize("@ss.hasPermi('app:score:add')")
    @Log(title = "成绩信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AppScore appScore)
    {
        return toAjax(appScoreService.insertAppScore(appScore));
    }

    /**
     * 修改成绩信息
     */
    @PreAuthorize("@ss.hasPermi('app:score:edit')")
    @Log(title = "成绩信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AppScore appScore)
    {
        return toAjax(appScoreService.updateAppScore(appScore));
    }

    /**
     * 删除成绩信息
     */
    @PreAuthorize("@ss.hasPermi('app:score:remove')")
    @Log(title = "成绩信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{scoreIds}")
    public AjaxResult remove(@PathVariable Long[] scoreIds)
    {
        return toAjax(appScoreService.deleteAppScoreByScoreIds(scoreIds));
    }
}
